#配置要评测的模型1
from langchain.evaluation import load_evaluator
from langchain_ollama import ChatOllama
from langchain_openai import OpenAI
#使用enum格式加载标准
from langchain.evaluation import EvaluatorType

llm = ChatOllama(model="qwen3:30b")
evaluator = load_evaluator("criteria",
                           llm=llm,
                           criteria="conciseness")
#input 输入的评测问题
#prediction 预测的答案
# 返回值 Y或者N是否符合
# 返回值score 1-0分数，1为完全，0为不完全
# eval_result = evaluator.evaluate_strings(
#     prediction="What's 2+2? That's an elementary question. The answer you're looking for is that two and two is four.",
#     input="What's 2+2?",
# )
# print(eval_result)


#自定义评估标准
custom_criterion = {
    "幽默性": "输出的内容是否足够幽默或者包含幽默元素",
    # "准确性": "输出的内容是否符合客观事实"
}
eval_chain = load_evaluator(
    EvaluatorType.CRITERIA,
    llm=llm,
    criteria=custom_criterion,
)
query = "给我讲一个笑话"
prediction = "有一天，小明去买菜，结果买了一堆菜回家，结果发现自己忘了带钱。"
# query = "2 + 2 = ?"
# prediction = "4"
eval_result = eval_chain.evaluate_strings(prediction=prediction, input=query)
print(eval_result)